package com.ideaaedi.log4j2.defender.plugin;

import com.ideaaedi.log4j2.defender.defender.Log4j2MessageDefender;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.message.Message;
import org.springframework.stereotype.Component;

/**
 * (non-javadoc)
 *
 * @author JustryDeng
 * @since 2021/7/25 12:28:26
 */
@Component
public class PluginTwo implements Log4j2MessageDefender {
    
    public static final String HANDLE_BY_PLUGIN = "PluginOneXyz";
    
    @Override
    public boolean support(LogEvent event) {
        return event.getContextData().containsKey(HANDLE_BY_PLUGIN);
    }
    
    @Override
    public void desensitize(LogEvent event, Message message, StringBuilder buffer) {
        buffer.append("[O_-] ").append(message.getFormattedMessage()).append(" [O_-]");
    }
}
